import * as THREE from "three";
import gsap from "gsap";
export class FlyLine {
  // 1.创建曲线
  lineCurve: THREE.CatmullRomCurve3 | null = null;
  geometry:THREE.TubeBufferGeometry|null = null;
  material:THREE.MeshBasicMaterial|null = null;
  mesh:THREE.Mesh|null = null;
  z11: THREE.Texture|null = null;
  constructor() {
    // 根据点生成曲线
    let linePoints = [
        new THREE.Vector3(-10, 0, 0),
     
      new THREE.Vector3(-8, 4, 0),
      new THREE.Vector3(0, 0, 0),
      
    ];
    this.lineCurve = new THREE.CatmullRomCurve3(linePoints);
    // 根据曲线生成管道
    this.geometry = new THREE.TubeBufferGeometry(this.lineCurve, 100, 0.4, 2, false);
    this.z11 = new THREE.TextureLoader().load("./textures/z_11.png");
    this.z11.repeat.set(1, 2);
    // 水平的重复
    this.z11.wrapS = THREE.RepeatWrapping;
    // 垂直的重复
    this.z11.wrapT =THREE.MirroredRepeatWrapping
    this.material = new THREE.MeshBasicMaterial({
        // color:0xfff000
        map:this.z11,
        transparent:true,

    })
    this.mesh = new THREE.Mesh( this.geometry, this.material );

    // 创建飞线动画
    gsap.to(this.z11.offset,{
        x:-1,
        duration:1,
        repeat:-1,
        ease:'none'
    })
  }
}
